﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AdvanceLib;
using AdvanceLib.ScriptCore;

namespace ACompiler.SystemCommands
{
    public class ReloadPlugins : SystemCommand, IHelpEntity
    {
        #region SystemCommand Member
        public override string Name
        {
            get { return "reloadplugins"; }
        }
        public override int ExpectedParameters
        {
            get { return 0; }
        }
        public override void Execute(ScriptHost host, string[] parameters)
        {
            try
            {
                host.ReloadPlugins();
                host.ExtensionManager.SystemCommands.AddRange(Program.GetCommands());

                Program.WriteLine("Plugins were reloaded successfully.", ConsoleColor.Green);
            }
            catch
            {
                Program.WriteLine("Error reloading plugins.", ConsoleColor.Red);
            }
        }
        public override bool DebugParameter(int paramIndex, string paramValue)
        {
            return true;
        }
        #endregion

        #region IHelpEntity Member
        public string GetParameterString()
        {
            return string.Empty;
        }
        public string GetDescription()
        {
            return "Clears the plugin list and reloads all plugins.";
        }
        #endregion
    }
}
